//
//  Item.swift
//  SwiftUILean
//
//  Created by wyknmjj on 2024/5/13.
//

import SwiftUI

struct PhotoItem: Identifiable,Hashable{
    var id: String=UUID().uuidString
    var title: String
    var image: UIImage?
    var previewImage: UIImage?
    var appeared: Bool=false
}



func getSamplePhotoItems()async ->  [PhotoItem]{
    return await withTaskGroup(of: PhotoItem.self) { group in
        Array(1...30).forEach { i in
            group.addTask {
               let image = try! await fetchImage("https://loremflickr.com/320/240/paris,girl/all")
               return PhotoItem(title: "title\(i)",image: image,previewImage: image)
            }
        }
            
        var data: [PhotoItem] = []
        for await i in group { data.append(i) }
        return data
    }
}
